package com.tgg.treeproject.utils;


import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.HashMap;

public class SMSUtil {
    public SMSUtil() {
    }

    public String  sendMessage(String phoneNumber, String SMScode) throws UnsupportedEncodingException {
        String gbk = URLEncoder.encode("验证码："+SMScode.trim()+"，打死都不要告诉别人哦！", "GBK");
        System.out.println(gbk);
        String url = "http://api01.monyun.cn:7901/sms/v2/std/single_send";
        HashMap<String, Object> paramMap = new HashMap<>();
        paramMap.put("apikey","a67c63d031a39bf4271c2288a3613e0c");
        paramMap.put("mobile",phoneNumber.trim());
        paramMap.put("content",gbk);
        paramMap.put("svrtype","SMS001");
        paramMap.put("exno","0006");
        paramMap.put("custid","b3d0a2783d31b21b8573");
        paramMap.put("exdata","exdata000002");
        String result= HttpUtil.post(url, JSONUtil.toJsonStr(paramMap));

        return result;
    }

}
